<template>
  <div class="app-container">
    <u-page title="退券记录">
      <u-filtered>
        <el-form :inline="true" :model="listQuery" class="search-form">
          <el-form-item label="退券时间" prop="searchDate">
            <u-date-time-picker v-model="daterange" @change="changeDate" />
          </el-form-item>
          <el-form-item label="会员卡号" prop="cardNo">
            <el-input v-model="listQuery.cardNo" placeholder="请输入会员卡号" clearable style="width: 170px" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="hdlFilter">搜索</el-button>
          </el-form-item>
        </el-form>
      </u-filtered>
      <u-table
        :data="list"
        :loading="listLoading"
        :options="listOptions"
        :columns="columns"
        :pagination.sync="listQuery"
        :fetch="hdlList"
        @selection-change="hdlSelectChange"
      >
      </u-table>
    </u-page>

    <el-drawer
      title="小票明细"
      :visible.sync="orderShow"
      direction="rtl"
      size="440px">
      <el-table :data="orderList">
        <el-table-column property="saleNo" label="订单号" width="200"></el-table-column>
        <el-table-column property="saleAmount" label="订单金额" width="100"></el-table-column>
        <el-table-column property="validAmount" label="有效金额" width="100"></el-table-column>
      </el-table>
    </el-drawer>
  </div>
</template>

<script>
export default {
  data() {
    return {
      api: this.$u.api.RebatenewRefund,
      daterange: [],
      orderShow: false,
      listQuery: {
        page: 1,
        pageSize: 10,
        totalCount: 1,
        beginTime: '',
        endTime: ''
      },
      // 表格
      columns: [
        {
          prop: 'schedulename',
          label: '档期主题'
        },
        {
          prop: 'operationcouponname',
          label: '活动名称'
        },
        {
          prop: 'custno',
          label: '顾客编号'
        },
        {
          prop: 'cardno',
          label: '会员卡号'
        },
        {
          prop: 'sumvalidamount',
          label: '金额'
        },
        {
          prop: 'createdby',
          label: '操作人'
        },
        {
          prop: 'createdat',
          label: '操作时间',
          sortable: true,
          timestamp: true
        }
      ],
      listLoading: false,
      list: [],
      orderList: [],
      listOptions: {
        stripe: true
      }
    }
  },
  created() {
    this.hdlList()
  },
  methods: {
    changeDate(item) {
      if (item) {
        this.listQuery.beginTime = item[0]
        this.listQuery.endTime = item[1]
      } else {
        this.listQuery.beginTime = ''
        this.listQuery.endTime = ''
      }
    }
  }
}
</script>

<style scoped>

</style>
